
//
//  SettingVC.m
//  ProjectSource_Demo
//
//  Created by Liu on 16/3/24.
//  Copyright © 2016年 AngryBear. All rights reserved.
//

#import "SettingVC.h"
#import "FeedbackVC.h"
#import "ChatRecordVC.h"
#import "NoticeVC.h"
#import "PrivacyVC.h"

#import "SettingCell.h"

@interface SettingVC ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation SettingVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithHexRGB:0xefefef];
    self.title = @"设置";
    [self.view addSubview:self.tableView];
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SettingCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SettingCell class])];
    cell.titleLabel.hidden = NO;
    cell.rightArrow.hidden = NO;
    
    switch (indexPath.row) {
        case 0:
        {
            cell.titleLabel.text = @"新消息通知";
        }
            break;
        case 1:
        {
            cell.titleLabel.text = @"消除所有聊天记录";
        }
            break;
        case 2:
        {
            cell.titleLabel.text = @"隐私";
        }
            break;
        case 3:
        {
            cell.titleLabel.text = @"意见与反馈";
            cell.bottomLine.hidden = YES;
        }
            break;
            
        default:
            break;
    }
    return cell;
}


#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 47;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row) {
        case 0:
        {
            NoticeVC *vc = [[NoticeVC alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1:
        {
            ChatRecordVC *vc = [[ChatRecordVC alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 2:
        {
            FeedbackVC *vc = [[FeedbackVC alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 3:
        {
            PrivacyVC *vc = [[PrivacyVC alloc] init];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
}

#pragma mark - Getter Methods
- (UITableView *)tableView
{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.bounces = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        _tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 15)];
        
        [_tableView registerClass:[SettingCell class] forCellReuseIdentifier:NSStringFromClass([SettingCell class])];
    }
    return _tableView;
}

@end
